package controller.delete;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.db.MyDBAccess;
/**
 * Servlet implementation class Delete_Completion
 */
@WebServlet("/DeleteCompletion")
public class DeleteCompletion extends HttpServlet {
	private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteCompletion() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		// 内容: データベースにアクセスする
		// MyDBAccess のインスタンスを生成する
		MyDBAccess db = new MyDBAccess();
		// データベースへのアクセス
		try {
			db.open();
		} catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		String employee_no = request.getParameter("employee_no");

		String sql = "delete from employee_info where employee_no = \'"
				+ employee_no + "\';";
		db.executeUpdate(sql);
		try {
			db.close();
		} catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		request.setCharacterEncoding("UTF-8");
		//RequestDispatcher
		ServletContext sc = getServletContext();
		RequestDispatcher rd = sc.getRequestDispatcher("/DeleteCompletion.jsp");
		//forward
		rd.forward(request, response);
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}